package com.wwy.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.wwy.module.TbOrder;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Objects;

/**
 * @author 王伟羽
 * @date 2024/11/1 13:47
 */
@Mapper
public interface TbOrderMapper extends BaseMapper<TbOrder> {

    /**
     * 查询列表数据
     * @param tbOrder
     * @return
     */
    default List<TbOrder> selectList(TbOrder tbOrder){
        return selectList(new LambdaQueryWrapper<TbOrder>()
        .eq(StringUtils.isNotBlank(tbOrder.getId()),TbOrder::getId,tbOrder.getId())
        .eq(StringUtils.isNotBlank(tbOrder.getOrderId()),TbOrder::getOrderId,tbOrder.getOrderId())
        .eq(Objects.nonNull(tbOrder.getStatus()),TbOrder::getStatus,tbOrder.getStatus())
        .eq(StringUtils.isNotBlank(tbOrder.getUserId()),TbOrder::getUserId,tbOrder.getUserId())
        .like(StringUtils.isNotBlank(tbOrder.getMsg()),TbOrder::getMsg,tbOrder.getMsg()));
    }
}
